<?php
/**
 *  NevuxBB - Free Forum Software
 *  Copyright (C) 2008, 2010 NevuxBB (No one specific author)*  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Modrewrite Class
 * File: modrewrite_class.php
 * Purpose: Converting conventional URLs
 * to search engine friendly URLs
 * Todo: Actually implement it, improve commenting, finish functions
 *
 */

class mod_rewrite {
	static $is_on;
	
	function __construct() {
		// is mod_rewrite turned on?
		if(GlobalSettings::getSetting('modrewrite') == 1) {
			// modrewrite is set to be turned on
			if(GlobalSettings::getSetting('modrewrite_check') == 1) {
				// is mod_rewrite available ?
				if(!file_exists(BASE_PATH . '/.htaccess')) {
					// mod_rewrite isn't available
					self::$is_on = false;
				} else {
					// mod_rewrite exists, but, is it there?
					$access_file = @file_get_contents(BASE_PATH . '/.htaccess');
					
					if(preg_match('/RewriteEngine on/', $access_file)) {
						// mod_rewrite is more than likely there
						self::$is_on = true;
					} else {
						// wont work anyway
						self::$is_on = false;
					}
				}
			} else {
				self::$is_on = true;
			}
		} else {
			// disabled
			self::$is_on = false;
		}
	}
	
	protected function isOn() {
		if(self::$is_on === true) {
			return true;
		} else {
			return false;
		}
	}
	
}

?>